<tpl var layoutStyle={ />
<style>
	.layui-table-cell .layui-form-checkbox[lay-skin="primary"]{
		padding-left: 28px;
	}
</style>
<tpl }; />
<tpl var layoutBody={ />
<div>
	<div class="layui-breadcrumb">
		<a href="/platform/index.jspx">数据表</a>
		<a href="javascript:;"><cite>字段选择</cite></a>
	</div>
	<hr>
	<form class="layui-form layui-form-pane" action="">
		<div class="layui-form-item layui-inline nobottom">
			<label class="layui-form-label width-auto">数据库表</label>
			<div class="layui-input-inline">
				<input type="text" name="table" placeholder="请输入数据库表" autocomplete="off" class="layui-input" value="${table!}" readonly>
			</div>
		</div>
		<div class="layui-form-item layui-inline nobottom">
			<label class="layui-form-label width-auto">相对包路径</label>
			<div class="layui-input-inline">
				<input type="text" name="package" placeholder="请输入相对包路径" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-inline nobottom">
			<label class="layui-form-label width-auto">页面名称</label>
			<div class="layui-input-inline">
				<input type="text" name="name" placeholder="请输入页面名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-inline nobottom">
			<button class="layui-btn" lay-submit lay-filter="formDemo">立即生成</button>
		</div>
	</form>
	<table class="layui-table" lay-data="{height: 'full-220', page: false, loading:true, url:'columns.json?table=${table!}'}">
		<thead>
			<tr>
				<th lay-data="{type:'numbers'}">ID</th>
				<th lay-data="{align:'center', toolbar: '#toolbar-tpl'}">作用域</th>
				<th lay-data="{field:'name'}">表名</th>
				<th lay-data="{field:'type'}">类型</th>
				<th lay-data="{field:'isnull'}">为空</th>
				<th lay-data="{field:'comment'}">备注</th>
			</tr>
		</thead>
	</table>
</div>
<tpl }; />

<tpl var layoutScript={ />
<script>
	layui.use(['element', 'table', 'form'], function () {
		layui.form.on('submit(formDemo)', function (data) {
			var param = {
				'name': data.field.name,
				'table': data.field.table,
				'package': data.field.package
			};

			// 获取字段列表
			$.each(['viewList', 'indexList', 'createList', 'updateList'], function () {
				param[this] = $('.table-column input[name="' + this + '"]:checked').map(function () {
					return $(this).parent().data();
				}).toArray();
			});

			// 表单提交
			$.jsonLoading('build.json', param, function (result) {
				layer.msg(result.message || "提交成功", {
					icon: 1,
					time: 1500
				});
			});

			return false;
		});
	});
</script>
<script type="text/html" id="toolbar-tpl">
	<div class="layui-btn-group table-column" data-name="{{d.name}}" data-type="{{d.type}}" data-isnull="{{d.isnull}}" data-comment="{{d.comment}}">
		<input type="checkbox" name="viewList" lay-skin="primary" title="查看" checked>
		<input type="checkbox" name="indexList" lay-skin="primary" title="列表" checked>
		<input type="checkbox" name="createList" lay-skin="primary" title="添加" checked>
		<input type="checkbox" name="updateList" lay-skin="primary" title="编辑" checked>
	</div>
</script>
<tpl }; />

<tpl include( "../../tpl/layout.html" ,{identity: "platform:table" ,layoutStyle:layoutStyle,layoutBody:layoutBody,layoutScript:layoutScript}){} />